#!/bin/bash

# architecture prefix
ARCH=arm-linux
VERSION="2.95.3"

# path to the toolchain and kernel base
TOOL_PATH=/usr/local/arm

# path to the toolchain base
BASE_PATH=$TOOL_PATH/$VERSION

# cumulative toolchain prefix
PREFIX=$BASE_PATH/bin/$ARCH

export CC=$PREFIX-gcc
export CXX=$PREFIX-g++
export LD=$PREFIX-ld
export NM="$PREFIX-nm -B"
export AR=$PREFIX-ar
export RANLIB=$PREFIX-ranlib
export STRIP=$PREFIX-strip
export OBJCOPY=$PREFIX-objcopy
export LN_S="ln -s"

export CFLAGS="-g -O2 -I$BASE_PATH/include"
export CPPFLAGS="-I$BASE_PATH/include"
export CXXFLAGS=""

export LDFLAGS="-L$BASE_PATH/lib -L$BASE_PATH/$ARCH/lib -L$BASE_PATH/lib/gcc-lib/$ARCH/$VERSION"

PATH=$BASE_PATH/bin:$PATH
./configure --build=`./config.guess` --host=$ARCH --prefix=$BASE_PATH $1 $2 $3
